<template>
<div class="top_box">
	<div class="right_box">
		<Button @click="refresh"><Icon type="md-sync" size="16" style="margin-right:5px;" />刷新</Button>
		<slot name="right"></slot>
	</div> 
	<div class="left_box">
		<h4>{{title}}</h4>
		<!--span class="date">当前期间：{{date}}</span-->
		<span class="date" v-if="next_month">当前期间：{{next_month}}</span>
		<span class="date" v-else>当前期间：{{date}}</span>
	</div>
</div>

</template>
<script>
export default {
	inject:['reload'],
	data:function(){
		return{		
			date:'',
			next_month:''
		};
	},
	props:{
		title:{
			default:'标题'
		},
	    nextMonth:''
	},
	created:function(){
	
		var date = new Date();
		var year = date.getFullYear();
		var month = date.getMonth();
		
		this.date = year + '年'+(month+1)+'月';

		if(typeof(this.nextMonth) !='undefined'){ this.load_data(); }
	},
	methods:{
		refresh(){
			this.reload();
		},
		load_data(){//查看当前月份是否已经 会计期末结账
			var self = this;
			var postdata = {
				date_month:new Date().Format('yyyy-MM')
			};
			Whttp.load("Accounting/Checkout/getBalance", postdata, function(result) {
				if(result){
					self.next_month = result;
					self.$emit('sendMonthDate',result);
				}
			},function(result){
				self.err_msg = result.message;
			});
		},
	}
}
</script>
<style scoped>

.top_box{
	background: #f2f2f2;
    overflow: hidden;
    height: 50px;
    line-height: 50px;
    border-bottom: 1px solid #ddd;
	font-size: 13px;
}
.top_box .right_box{
	float: right;
    margin-right: 20px;
}
.top_box .left_box{
	overflow: hidden;
}
.top_box .left_box h4{
	    border-left: 3px solid rgba(26, 188, 156, 0.8);
    line-height: 22px;
    padding-left: 15px;
    color: #999999;
    font-weight: normal;
    
	display: inline-block;
	    margin-right: 25px;
}
.date{
	
}
</style>